package com.lin.videospringboot.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lin.videospringboot.been.Video;
import com.lin.videospringboot.been.VideoComment;
import com.lin.videospringboot.mapper.VideoCommentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class VideoCommentImpt {

    @Autowired
    VideoCommentMapper videoCommentMapper;

    public int addVideoComment(VideoComment videoComment) {
        return videoCommentMapper.insert(videoComment);
    }

    public List<Map<String,Object>> getVideoCommentListWithUserInfo(int videoId) {
        QueryWrapper<VideoComment> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("videoId",videoId);
        return videoCommentMapper.getVideoCommentWithUserInfo(videoId);
    }

    public VideoComment getVideoCommentById(int videoCommentId) {
        return videoCommentMapper.selectById(videoCommentId);
    }

    public int updateVideoComment(VideoComment videoComment) {
        return videoCommentMapper.updateById(videoComment);
    }
}
